/*
 * @Author: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @Date: 2022-10-21 11:12:49
 * @LastEditors: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @LastEditTime: 2022-10-25 14:53:30
 * @FilePath: \宏烨找房\用户端\app\demo\src\page\Login\index.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import React from 'react'
import { Form, Button, Input, Notify } from 'react-vant';
import { useNavigate } from 'react-router-dom'
import { httpSign } from '../../api/login'
import './index.css'
const Sign = () => {
    const [form] = Form.useForm()
    const navigate = useNavigate()
    const onFinish = async (values) => {
        const res = await httpSign('/sign', values);
        if (res.data.code === 200) {
            Notify.show({ type: 'primary', message: res.data.msg })
            navigate('/login')
        }else{
            Notify.show({ type: 'primary', message: res.data.msg })
        }
    }
    return (
        <div className='login'>
            <div style={{ marginTop: '100px', marginLeft: '160px'}}> <h1>注册</h1> </div>
            <div className="login-box">
                <Form
                    form={form}
                    onFinish={onFinish}
                    style={{ padding: '30px' }}
                    footer={
                        <div style={{ margin: '16px 16px 0' }}>
                            <Button round nativeType='submit' type='primary' block>
                                注册
                            </Button>
                        </div>
                    }
                >
                    <Form.Item
                        tooltip={{
                            message:
                                'A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself.',
                        }}
                        intro='确保这是唯一的用户名'
                        rules={[{ required: true, message: '请填写用户名' }]}
                        name='username'
                        label='用户名'
                    >
                        <Input placeholder='请输入用户名' />
                    </Form.Item>
                    <Form.Item
                        rules={[{ required: true, message: '请填写密码' }]}
                        name='password'
                        label='密码'
                    >
                        <Input placeholder='请输入密码' />
                    </Form.Item>
                </Form>

                <a href="/login">返回登录页面 </a>
            </div>


        </div>
    )
}
export default Sign;